<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" lang="zh">
<head>
    <th:block th:include="include :: header('用户发布任务列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>任务名称：</label>
                            <input type="text" name="taskName"/>
                        </li>
                        <li>
                            <label>电话号码：</label>
                            <input type="text" name="phonenumber"/>
                        </li>
                        <li>
                            <label>任务状态：</label>
                            <select name="taskStatus" th:with="type=${@dict.getType('user_task_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>发布账号：</label>
                            <input type="text" name="createBy"/>
                        </li>
                        <li class="select-time">
                            <label>创建时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-danger multiple disabled" onclick="javascript:checkUserTask()"
               shiro:hasPermission="task:usertask:check">
                <i class="fa fa-check-circle"></i> 审核
            </a>
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="task:usertask:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('task:usertask:edit')}]];
    var removeFlag = [[${@permission.hasPermi('task:usertask:remove')}]];
    var taskStatus = [[${@dict.getType('user_task_status')}]];
    var prefix = ctx + "task/usertask";

    $(function () {
        var options = {
            url: prefix + "/checklist",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "校园任务审查",
            clickToSelect: true,
            columns: [{
                radio: true
            },
                {
                    field: 'taskId',
                    title: '任务id',
                    visible: false
                },
                {
                    field: 'taskName',
                    align: 'center',
                    title: '任务名称'
                },
                {
                    field: 'taskDescription',
                    align: 'center',
                    title: '任务描述'
                },

                {
                    field: 'money',
                    align: 'center',
                    title: '赏金'
                },
                {
                    field: 'phonenumber',
                    align: 'center',
                    title: '电话号码'
                },
                {
                    field: 'address',
                    align: 'center',
                    title: '地址'
                },
                {
                    field: 'createBy',
                    align: 'center',
                    title: '创建者'
                },
                {
                    field: 'createTime',
                    align: 'center',
                    title: '创建时间'
                },
                {
                    field: 'taskStatus',
                    align: 'center',
                    /* 0：待审核 1：待审核 2：审核通过 */
                    title: '任务状态',
                    formatter: function (value, item, index) {
                        return $.table.selectDictLabel(taskStatus, item.taskStatus);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.taskId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    // 审核用户任务
    function checkUserTask() {
        var taskId = $.table.selectColumns("taskId");
        if (taskId.length == 0) {
            $.modal.alertWarning("请选择要审核的信息");
            return;
        } else {
            var url = prefix + '/checkTask/' + taskId;
            $.modal.openTab("审核详情", url);
        }
    }

</script>
</body>
</html>